package com.wyz.socket.core.utils;

public class Log {
    public static boolean isEnablePrintlnDebug = true;
    public static boolean isEnablePrintlnInfo = true;
    public static boolean isEnablePrintlnError = true;

    public static void printlnInfo(String key, Object obj) {
        println(isEnablePrintlnInfo, key, obj);
    }

    public static void printlnDebug(String key, Object obj) {
        println(isEnablePrintlnDebug, key, obj);
    }

    public static void printlnError(String key, Object obj) {
        println(isEnablePrintlnError, key, obj);
    }

    private static void println(boolean isEnablePrintln, String key, Object obj) {
        if (isEnablePrintln) {
            System.out.println(key + " : " + obj.toString());
        }
    }

    public static void println( String key, Object obj) {
        System.out.println(key + " : " + obj.toString());
    }

    public static void println( Object clazz, Object func , Object mas) {
        System.out.println(clazz.toString()+ " : " + func.toString() +" : "+mas);
    }


    public static void printException(String key, Object obj, Throwable throwable) {
        throwable.printStackTrace();
        Log.printlnError(key, makeString(obj.toString(), throwable.getLocalizedMessage()));
    }

    public static String makeLnString(String key, Object obj) {
        return "\n" + key + " : " + obj.toString();
    }

    public static String makeString(String key, Object obj) {
        return key + " : " + obj.toString();
    }
}
